package com.edu.exam.enums.core;

/**
 * 标准类型枚举
 */
public enum StandardType {
    ACADEMIC("ACADEMIC", "学术标准"),
    TECHNICAL("TECHNICAL", "技术标准"),
    PROFESSIONAL("PROFESSIONAL", "专业标准"),
    INDUSTRY("INDUSTRY", "行业标准"),
    NATIONAL("NATIONAL", "国家标准"),
    INTERNATIONAL("INTERNATIONAL", "国际标准"),
    INSTITUTIONAL("INSTITUTIONAL", "机构标准"),
    DEPARTMENTAL("DEPARTMENTAL", "部门标准");

    private final String code;
    private final String description;

    StandardType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static StandardType fromCode(String code) {
        for (StandardType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown StandardType code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}